#ifndef __SHMCOP_H__
#define __SHMCOP_H__

#include <QObject>
#include <QtCore>

#define SHMKEY_N2L "8948"
#define SHMKEY_L2N "8949"

#define SEMKEY_L2N_Pro "L2NPro1"
#define SEMKEY_N2L_Pro "N2LPro1"
#define SEMKEY_L2N_Con "L2NCon1"
#define SEMKEY_N2L_Con "N2LCon1"
#define SHMSIZE 1048576
typedef enum
{
    L2N=1,
    N2L=2,
    PRO_N,
    PRO_L
}shmDirection;


class ShmCop : public QThread
{
	Q_OBJECT
public:
	ShmCop();
	~ShmCop();
	void SendData(QByteArray & data, shmDirection d);
protected:
    void run();
signals:
	void dataArrived(const QByteArray & data);	
private:
    QSharedMemory shmL2N;
    QSharedMemory shmN2L;
    QSystemSemaphore semL2N_Con;
    QSystemSemaphore semN2L_Con;
    QSystemSemaphore semL2N_Pro;
    QSystemSemaphore semN2L_Pro;        
    	QBuffer buffer;	
};

#endif //__SHMCOP_H__